package cn.lesaas.esb.poc.sql;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

public class JobsDao {
    private final JdbcTemplate jdbcTemplate;

    public JobsDao(DataSource dataSource) {
        jdbcTemplate = new JdbcTemplate(dataSource);
    }

    public int getMessageCount(String sequence) {
        return jdbcTemplate.queryForObject("select count(*) from jobs where sequence = ?", Integer.class, sequence);
    }
    
    public List getMessages(String sequence) {
    	return jdbcTemplate.queryForList("select message from jobs where sequence = ?", sequence);
    }
}
